import { Component, OnInit,Input,ViewChild } from '@angular/core';
import { Router, NavigationExtras,ActivatedRoute } from '@angular/router';
import { Platform,NavController  } from '@ionic/angular';

@Component({
  selector: 'app-common-error',
  templateUrl: './common-error.page.html',
  styleUrls: ['./common-error.page.scss'],
})
export class CommonErrorPage implements OnInit {
  title:string;
  errorContent:string = '';
  // //errType: 0-empty state / 1- system error / 2-network error
  errType:number;
  backBtn :boolean = true;
  backUrl:string;
  emptyState = '../../../../assets/images/ios/emptystate.png';
  systemError = '../../../../assets/images/ios/dataissues.png';
  networkError = '../../../../assets/images/ios/networkissues.png';
  imgSrc = '';

  constructor(
    private router: Router,
    public navController: NavController,
    private activeRouter : ActivatedRoute
  ) {
    this.activeRouter.queryParams.subscribe((data)=>{
      this.errorContent = data.errorContent;
      this.title = data.title;
      this.backUrl = data.backUrl;
      if(data.errType == 0){
       this.backBtn = false;
       this.imgSrc = this.emptyState;
      }else if(data.errType == 1){
       this.imgSrc = this.systemError;
      }else{
       this.imgSrc = this.networkError;
      }
    });

  }

 
  ngOnInit() {
   
  }

  ngAfterViewInit(): void {
   
    
  }

  back(){
    this.router.navigate(['/tabs/home']);
  }
}
